<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>发票登记信息管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/typeahead/bootstrap-typeahead.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			
			//设置重置按钮
			$("#btnReset").click(function(){
				$(':input','#searchForm').not(':button, :submit, :reset, .notReset').val('').removeAttr('checked').removeAttr('selected');
				$(".select2-chosen").text('');
				/**var form = $(this).parents("form:first");
				$(this).parents("form:first")[0].empty();
				$(this).parents("form:first")[0].reset();
//		         设置下拉选择
				 form.find("select").each(function(){
					 var option = $(this).find("option:selected");
					 var selectVal = option.val();
					 var selectText = option.html();
					 $(this).next("span").find(".textbox-value").val(selectVal);
					 $(this).next("span").find(".textbox-text").val(selectText);
				 });*/
			});
			
			/**导出excel*/
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认导出数据？", "系统提示", function(v, h, f) {
					if (v == 'ok') {
						var action = $("#searchForm").attr('action');
						$("#searchForm").attr("action","${ctx}/inv/invInfo/export");
						$("#searchForm").submit();
						$("#searchForm").attr("action",action);
					}
				});
			});
			
		});
		function page(n,s){
			if(n){
				$("#pageNo").val(n);
			}
			if(s){
				$("#pageSize").val(s);
			}
			$("#searchForm").submit();
        	return false;
        }
		
		//详情
		function detail(id){
                var iframeUrl = "${ctx}/inv/invInfo/form?operateFlag=9&id="+id;
				top.$.jBox.open("iframe:"+iframeUrl, "开票信息详情", 900,500, {
		            buttons:{}, submit:function(v, h, f){
		                if (v=="ok"){
		                }
		            }, loaded:function(h){
		                $(".jbox-content", top.document).css("overflow-y","hidden");
		            }, closed: function () { 
		    			page();
		            }
		        });
		}
		
		function del(id){
			confirmx('确认要删除该发票信息吗？', function(){
				 return $.ajax({
		                url: '${ctx}/inv/invInfo/delete',
		                type: 'post',
		                data: {id: id},
		                success: function (result) {
		                	if(result=='success'){
		                		showTip('删除成功！');
		                		page();
		                	}else{
		                		showTip('删除失败！')
		                	}
		                },
		            })
			})
		}
	</script>
	<style type="text/css">
	.form-search .ul-form li label{
	width: 120px !important;
	}
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="">开票登记查询</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="invInfo" action="${ctx}/inv/invInfo/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="operateFlag" name="operateFlag" type="hidden" value="${invInfo.operateFlag}" class="notReset"/>
		<ul class="ul-form">
		<li>
		<label>开票单位/车牌号：</label><span style="padding-left:3px"><form:input path="invDeptName" htmlEscape="false" maxlength="50" class="input-medium"/></span>
		<label>发票编号：</label><span style="padding-left: 3px"><form:input path="invCode" htmlEscape="false" maxlength="50" class="input-medium"/></span>
		<li class="clearfix"></li>
		<li>
		<label>发票类型：</label>
				<form:select path="invType" class="select-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('INV_TYPE')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
		<label >报销人：</label><span style="padding-left: 3px"><form:input path="createBy.name" htmlEscape="false" maxlength="50" class="input-medium"/></span>
		</li> 
		<li class="clearfix"></li>
		<li>
			<label>报销类型：</label>
			<form:select path="claimType" class="select-medium">
			   <form:option value=""></form:option>
				<form:options items="${fns:getDictList('INV_CLAIM_TYPE')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
		    <label>经办人：</label>
			<input name="transactName" type="text" class="input-medium" maxlength="20" value="${invInfo.transactName}" htmlEscape="false"/>
		</li>
		<li class="clearfix"></li>
		<li>
		    <label>开票日期：</label>
			<input name="invDateBegin" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${invInfo.invDateBegin}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
		<label>至：</label>
			<input name="invDateEnd" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${invInfo.invDateEnd}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
		</li>
		
		
			<li class="btns">
			<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
			<input id="btnReset" class="btn btn-reset" type="button" value="重置"/>
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>开票单位/车牌号</th>
				<th>发票编号</th>
				<th>报销类型</th>
				<th>开票金额</th>
				<th>开票日期</th>
				<th>开票类型</th>
				<th>状态</th>
				<th>经办人</th>
				<th>报销人</th>
				<th>录入时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="invInfo">
			<tr>
				<td><a href="javascript:detail('${invInfo.id}')">
					${invInfo.invDeptName}${invInfo.plateNo}
				</a></td>
				<td>${invInfo.invCode}</td>
				<td>${fns:getDictLabel(invInfo.claimType,'INV_CLAIM_TYPE',invInfo.claimType)}</td>
				<td>${invInfo.amout}</td>
				<td><fmt:formatDate value="${invInfo.invDate}" pattern="yyyy-MM-dd"/></td>
				<td>${fns:getDictLabel(invInfo.invType,'INV_TYPE','')}</td>
				<td>${invInfo.status eq '0'?'未提交':'已提交'}</td>
				<td>${invInfo.transactName}</td>
				<td>
					${invInfo.createBy.name}
				</td>
				<td><fmt:formatDate value="${invInfo.createDate}" pattern="yyyy-MM-dd"/></td>
				<td>
				    <a href="javascript:del('${invInfo.id}')" onclick="return ">删除</a>
				    <a href="javascript:detail('${invInfo.id}')">详情</a>
				</td>
			</tr>
		</c:forEach>
		<tr>
				<th colspan="3">汇总：</th>
				<th >${sumMap.AMOUT }</th>
				<th colspan="7"></th>
		</tr>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>